﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Templates/Template2.Master" Inherits="System.Web.Mvc.ViewPage<SushiWeb.Models.Cliente>" %>

<asp:Content ID="Content2" ContentPlaceHolderID="menuContent" runat="server">
<%
    //string[] menuArray = { "1", "0", "0", "0", "0", "0","0"};
    string[] menuArray = { "1", "0", "0", "0", "0" };
    Session["menuArray"] = menuArray;
%>
</asp:Content>

<asp:Content ID="Content1" ContentPlaceHolderID="body" runat="server">
    <script type="text/javascript">

        
        $(document).ready(function () {

            $(".datepicker").datepicker();
            // validar formulario
            $("#clienteForm").validate({
                submitHandler: function (form) {
                    submitForm("");
                },
                rules: {
                    Nombres: "required",
                    Apellidos: "required",
                    NumeroDocumento: "required",
                    Email: {
                        required: true,
                        email: true
                    },
                    Direccion: "required",
                    Telefono: "required",
                    FecNacimiento: "required",
                    Usuario: "required",
                    Contrasena: "required"

                }
            });

        });

        function submitForm() {

            var $form = $("#clienteForm");

            $.ajax({
                type: "POST",
                url: $form.attr('action'),
                data: $form.serialize(),
                error: function (xhr, status, error) {
                    $.msgBox({
                        content: error,
                        type: "error"
                    });
                },
                success: function (data) {
                    $("#loading-div-background").hide();
                    if (data.tipoMensaje == 'INFO') {
                        $.msgBox({
                            content: data.mensaje,
                            type: "info",
                            afterClose: function () {
                                window.location = data.redirectTo;
                            }
                        });
                    } else if (data.tipoMensaje == 'WARN') {
                        $.msgBox({
                            content: data.mensaje,
                            type: "alert"
                        });
                    }

                },
                beforeSend: function (data) {
                    $("#loading-div-background").show();
                }
            });

            return false;
        }
    </script>

    <h2 style="font-size: large">&nbsp;</h2>
    
    <% using (Html.BeginForm("Clientes", "Cliente", FormMethod.Post, new { id = "clienteForm", @class = "cmxform" }))
       {%>   
        <table style="width:100%;">
            <tr>
                <td colspan="4" style="font-size: medium">
                    <strong>Registro de Clientes</strong></td>
            </tr>
            <tr>
                <td style="width: 189px">
                    Usuario(*) :</td>
                <td>
                    <%: Html.TextBoxFor(model => Model.Usuario)%></td>
                <td>
                    Contraseña(*) :</td>
                <td>
                     <%: Html.PasswordFor(model => Model.Contrasena)%></td>
            </tr>
            <tr>
                <td style="width: 189px">
                    Nombres(*) :</td>
                <td>
                     <%: Html.TextBoxFor(model => Model.Nombres)%>
                </td>
                <td>
                    Apellidos(*) :</td>
                <td>
                    <%: Html.TextBoxFor(model => Model.Apellidos)%>
                </td>
            </tr>
            <tr>
                <td style="width: 189px">
                    Direccion(*) :
                </td>
                <td>
                    <%: Html.TextBoxFor(model => Model.Direccion)%>
                </td>
                <td>
                    Telefono(*) :</td>
                <td>
                     <%: Html.TextBoxFor(model => Model.Telefono)%>
                </td>
            </tr>
            <tr>
                <td style="width: 189px">
                    Numero de Doc.(*) :
                </td>
                <td>
                    <%: Html.TextBoxFor(model => Model.NumeroDocumento)%>
                </td>
                <td>
                    Fecha Nacimiento(*)  :</td>
                <td>
                    
                     <%: Html.TextBox("FecNacimiento", null, new { @class = "datepicker", @style = "width:100px;" })%>
                </td>
            </tr>
            <tr>
                <td style="width: 189px"> 
                Email(*) :</td>
                <td>
                      <%: Html.TextBoxFor(model => Model.Email)%>
                </td>
                <td>
                </td>
                <td>
                     
                </td>
            </tr>

            
            <tr>
                
                <td colspan="4" style="text-align: right">
                       <input id="btnSubmit" type="submit" value="Registrar Datos" class="button"/>
                </td>
                
            </tr>
        </table>
      
       <% } %>
  

</asp:Content>
